package cn.gok.server.controller;

import cn.gok.common.config.SystemLog;
import cn.gok.common.entity.goods.GoodsCategory;
import cn.gok.common.resp.Result;
import cn.gok.server.service.CategoryService;
import cn.gok.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: DxlinY
 * @apiNote: 商品分类用控制层
 * @date: 2020/11/4
 * @time: 11:37
 */
@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;


    /**
     * 商品品牌分类菜单
     *
     * @return
     */
    @PostMapping("/brandCateGoryToTree")
    @SystemLog(model = "商品品牌分类", method = "获取商品品牌分类下拉")
    public Result toTree() {
        return ResultUtil.success(categoryService.listToTree());
    }

    /**
     * 修改分类名称备注
     *
     * @param goodsCategory
     * @return
     */
    @PostMapping("/updateById")
    @SystemLog(model = "商品品牌分类", method = "修改分类名称备注")
    public Result updateById(GoodsCategory goodsCategory) {
        if (categoryService.updateById(goodsCategory) > 0) {
            return ResultUtil.success(null);
        }
        return ResultUtil.error(null);
    }
}
